﻿using APP.HELPER.Data.Helper;
using DevExpress.XtraEditors;
using System; using Extra.ERP;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms; using Common;

namespace HRM.CORE
{
    

    public class HRM_EMPLOYEE_ACTIVITY
    {
        private string m_Activity;
        private Guid m_ActivityID;
        private string m_Description;
        private string m_EmployeeCode;
        private DateTime m_FromDate;
        private string m_Position;
        private DateTime m_ToDate;
        private string m_Where;

        public HRM_EMPLOYEE_ACTIVITY()
        {
            this.m_ActivityID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_FromDate = DateTime.Now;
            this.m_ToDate = DateTime.Now;
            this.m_Activity = "";
            this.m_Where = "";
            this.m_Position = "";
            this.m_Description = "";
        }

        public HRM_EMPLOYEE_ACTIVITY(Guid ActivityID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Activity, string Where, string Position, string Description)
        {
            this.m_ActivityID = ActivityID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_FromDate = FromDate;
            this.m_ToDate = ToDate;
            this.m_Activity = Activity;
            this.m_Where = Where;
            this.m_Position = Position;
            this.m_Description = Description;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { this.EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ACTIVITY_Delete", myParams, myValues);
        }

        public string Delete(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ACTIVITY_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_ACTIVITY_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, string EmployeeCode, string AllowanceCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_EMPLOYEE_ACTIVITY_Delete", myParams, myValues);
        }

        private void DispError(object sender, SqlHelperException e)
        {
            XtraMessageBox.Show(e.Message, "Th\x00f4ng B\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }

        public bool Exist(Guid ActivityID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@ActivityID" };
            object[] myValues = new object[] { ActivityID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_EMPLOYEE_ACTIVITY_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid ActivityID)
        {
            string str = "";
            string[] myParams = new string[] { "@ActivityID" };
            object[] myValues = new object[] { ActivityID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_EMPLOYEE_ACTIVITY_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ActivityID = reader.GetGuid(reader.GetOrdinal("ActivityID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Activity = Convert.ToString(reader["Activity"]);
                    this.m_Where = Convert.ToString(reader["Where"]);
                    this.m_Position = Convert.ToString(reader["Position"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid ActivityID)
        {
            string str = "";
            string[] myParams = new string[] { "@ActivityID" };
            object[] myValues = new object[] { ActivityID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_EMPLOYEE_ACTIVITY_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ActivityID = reader.GetGuid(reader.GetOrdinal("ActivityID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Activity = Convert.ToString(reader["Activity"]);
                    this.m_Where = Convert.ToString(reader["Where"]);
                    this.m_Position = Convert.ToString(reader["Position"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid ActivityID)
        {
            string str = "";
            string[] myParams = new string[] { "@ActivityID" };
            object[] myValues = new object[] { ActivityID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_EMPLOYEE_ACTIVITY_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_ActivityID = reader.GetGuid(reader.GetOrdinal("ActivityID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_FromDate = Convert.ToDateTime(reader["FromDate"]);
                    this.m_ToDate = Convert.ToDateTime(reader["ToDate"]);
                    this.m_Activity = Convert.ToString(reader["Activity"]);
                    this.m_Where = Convert.ToString(reader["Where"]);
                    this.m_Position = Convert.ToString(reader["Position"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_EMPLOYEE_ACTIVITY_GetList", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@ActivityID", "@EmployeeCode", "@FromDate", "@ToDate", "@Activity", "@Where", "@Position", "@Description" };
            object[] myValues = new object[] { this.m_ActivityID, this.m_EmployeeCode, this.m_FromDate, this.m_ToDate, this.m_Activity, this.m_Where, this.m_Position, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ACTIVITY_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@ActivityID", "@EmployeeCode", "@FromDate", "@ToDate", "@Activity", "@Where", "@Position", "@Description" };
            object[] myValues = new object[] { this.m_ActivityID, this.m_EmployeeCode, this.m_FromDate, this.m_ToDate, this.m_Activity, this.m_Where, this.m_Position, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_ACTIVITY_Insert", myParams, myValues);
        }

        public string Insert(Guid ActivityID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Activity, string Where, string Position, string Description)
        {
            string[] myParams = new string[] { "@ActivityID", "@EmployeeCode", "@FromDate", "@ToDate", "@Activity", "@Where", "@Position", "@Description" };
            object[] myValues = new object[] { ActivityID, EmployeeCode, FromDate, ToDate, Activity, Where, Position, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ACTIVITY_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid ActivityID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Activity, string Where, string Position, string Description)
        {
            string[] myParams = new string[] { "@ActivityID", "@EmployeeCode", "@FromDate", "@ToDate", "@Activity", "@Where", "@Position", "@Description" };
            object[] myValues = new object[] { ActivityID, EmployeeCode, FromDate, ToDate, Activity, Where, Position, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_EMPLOYEE_ACTIVITY_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid ActivityID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Activity, string Where, string Position, string Description)
        {
            string[] myParams = new string[] { "@ActivityID", "@EmployeeCode", "@FromDate", "@ToDate", "@Activity", "@Where", "@Position", "@Description" };
            object[] myValues = new object[] { ActivityID, EmployeeCode, FromDate, ToDate, Activity, Where, Position, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_ACTIVITY_Insert", myParams, myValues);
        }

        public string Update()
        {
            string[] myParams = new string[] { "@ActivityID", "@EmployeeCode", "@FromDate", "@ToDate", "@Activity", "@Where", "@Position", "@Description" };
            object[] myValues = new object[] { this.m_ActivityID, this.m_EmployeeCode, this.m_FromDate, this.m_ToDate, this.m_Activity, this.m_Where, this.m_Position, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ACTIVITY_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@ActivityID", "@EmployeeCode", "@FromDate", "@ToDate", "@Activity", "@Where", "@Position", "@Description" };
            object[] myValues = new object[] { this.m_ActivityID, this.m_EmployeeCode, this.m_FromDate, this.m_ToDate, this.m_Activity, this.m_Where, this.m_Position, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_ACTIVITY_Update", myParams, myValues);
        }

        public string Update(Guid ActivityID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Activity, string Where, string Position, string Description)
        {
            string[] myParams = new string[] { "@ActivityID", "@EmployeeCode", "@FromDate", "@ToDate", "@Activity", "@Where", "@Position", "@Description" };
            object[] myValues = new object[] { ActivityID, EmployeeCode, FromDate, ToDate, Activity, Where, Position, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_EMPLOYEE_ACTIVITY_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid ActivityID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Activity, string Where, string Position, string Description)
        {
            string[] myParams = new string[] { "@ActivityID", "@EmployeeCode", "@FromDate", "@ToDate", "@Activity", "@Where", "@Position", "@Description" };
            object[] myValues = new object[] { ActivityID, EmployeeCode, FromDate, ToDate, Activity, Where, Position, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_EMPLOYEE_ACTIVITY_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid ActivityID, string EmployeeCode, DateTime FromDate, DateTime ToDate, string Activity, string Where, string Position, string Description)
        {
            string[] myParams = new string[] { "@ActivityID", "@EmployeeCode", "@FromDate", "@ToDate", "@Activity", "@Where", "@Position", "@Description" };
            object[] myValues = new object[] { ActivityID, EmployeeCode, FromDate, ToDate, Activity, Where, Position, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_EMPLOYEE_ACTIVITY_Update", myParams, myValues);
        }

        [Category("Column"), DisplayName("Activity")]
        public string Activity
        {
            get
            {
                return this.m_Activity;
            }
            set
            {
                this.m_Activity = value;
            }
        }

        [Category("Primary Key"), DisplayName("ActivityID")]
        public Guid ActivityID
        {
            get
            {
                return this.m_ActivityID;
            }
            set
            {
                this.m_ActivityID = value;
            }
        }

        [Category("Column"), DisplayName("Description")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [Category("Column"), DisplayName("EmployeeCode")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [DisplayName("FromDate"), Category("Column")]
        public DateTime FromDate
        {
            get
            {
                return this.m_FromDate;
            }
            set
            {
                this.m_FromDate = value;
            }
        }

        [Category("Column"), DisplayName("Position")]
        public string Position
        {
            get
            {
                return this.m_Position;
            }
            set
            {
                this.m_Position = value;
            }
        }

        [DisplayName("ToDate"), Category("Column")]
        public DateTime ToDate
        {
            get
            {
                return this.m_ToDate;
            }
            set
            {
                this.m_ToDate = value;
            }
        }

        [DisplayName("Where"), Category("Column")]
        public string Where
        {
            get
            {
                return this.m_Where;
            }
            set
            {
                this.m_Where = value;
            }
        }
    }
}

